package com.hunttown.mes.dao;

import com.hunttown.common.dao.base.BaseDao;
import com.hunttown.common.domain.Query;
import com.hunttown.mes.domain.LbsTerminalReceiveLog;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.List;

/**
 * created by wangjunfu on 2022-01-17 10:15:42
 */
public class LbsTerminalReceiveLogDao extends BaseDao {
    private static final Logger logger = LoggerFactory.getLogger(LbsTerminalReceiveLogDao.class);

    public LbsTerminalReceiveLog insert(final LbsTerminalReceiveLog lbsTerminalReceiveLog) {
        insert("LbsTerminalReceiveLog.insert", lbsTerminalReceiveLog);
        return lbsTerminalReceiveLog;
    }

    public Boolean updateInfoById(final LbsTerminalReceiveLog lbsTerminalReceiveLog) {
        return update("LbsTerminalReceiveLog.updateInfoById", lbsTerminalReceiveLog) > 0;
    }

    public Boolean updateInfoByQuery(final Query query) {
        return update("LbsTerminalReceiveLog.updateInfoByQuery", query) > 0;
    }

    public LbsTerminalReceiveLog selectById(final Integer id, final Integer entId) {
        Query query = Query.noPage();
        query.put("id", id);
        query.put("entId", entId);
        return queryForObject("LbsTerminalReceiveLog.selectById", query);
    }

    public List<LbsTerminalReceiveLog> selectByQuery(final Query query) {
        return queryForList("LbsTerminalReceiveLog.selectByQuery", query);
    }

    public Long countByQuery(final Query query) {
        return queryForObject("LbsTerminalReceiveLog.countByQuery", query);
    }

    public Boolean deleteById(final Integer id, final Integer entId) {
        LbsTerminalReceiveLog lbsTerminalReceiveLog = new LbsTerminalReceiveLog();
        lbsTerminalReceiveLog.setDeleteFlag(1);
        lbsTerminalReceiveLog.setId(id);
        lbsTerminalReceiveLog.setEntId(entId);

        return update("LbsTerminalReceiveLog.updateInfoById", lbsTerminalReceiveLog) > 0;
    }

    //物理删除不可恢复，慎用！
    public Boolean deleteByIdForPhysical(final Integer id) {
        Query query = Query.noPage();
        query.put("id", id);
        return delete("LbsTerminalReceiveLog.deleteById", query) > 0;
    }
}